package com.wolfden.drugserver.utils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class FileUtils {
	
	public static void save(String fileName, Object o) throws IOException {
		
		ObjectOutputStream output;

		try {
			output = new ObjectOutputStream(new FileOutputStream(fileName));
			output.writeObject(o);
			output.flush();
			output.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public static Object load(String fileName) throws IOException {

		Object toRet = null;
		try {
			ObjectInputStream input = new ObjectInputStream(
					new FileInputStream(fileName));
			toRet = input.readObject();
			input.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		return toRet;
	}
}
